package com.floreo.shopping.bo;

import com.floreo.shopping.model.Group;
import com.floreo.shopping.model.Product;
import com.floreo.shopping.model.Quantity;
import com.floreo.shopping.service.ServiceFactory;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * @author merzod
 */
public class SystemBOTest {
    private SystemBO service;

    @Before
    public void setUp() throws Exception {
        service = SystemBO.getInstance();
    }

    @Test
    public void testAdd() throws Exception {
        Product p = new Product("milk", new Group());
        Quantity q = new Quantity();
        service.addProduct(p, q);
        Assert.assertEquals(p, ServiceFactory.getInstance().getProductService().getProductByName("milk"));
        Assert.assertEquals(1, ServiceFactory.getInstance().getQuantityService().getQuantities(p).size());
        Assert.assertTrue(ServiceFactory.getInstance().getQuantityService().getQuantities(p).contains(q));
    }
}
